﻿<UserControl 
    x:Class="DiscoveryLogic.Analytics.Modules.Diagrams.RadialDiagrams.RadialGraphView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:RadialDiagrams="clr-namespace:DiscoveryLogic.Analytics.Modules.Diagrams.RadialDiagrams"
    MinWidth="400" MinHeight="300" VerticalAlignment="Stretch" 
    HorizontalAlignment="Stretch"
    Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <!-- animation when zoom area fades in -->
        <Storyboard x:Key="FadeInAnimation">
            <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.9" Duration="0:0:0.5" />
        </Storyboard>

        <!-- animation when zoom area fades out -->
        <Storyboard x:Key="FadeOutAnimation">
            <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.3" Duration="0:0:0.5" />
        </Storyboard>

        <!-- scroll viewer -->
        <Style x:Key="ScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
            <Setter Property="HorizontalScrollBarVisibility" Value="Hidden" />
            <Setter Property="VerticalScrollBarVisibility" Value="Hidden" />
        </Style>

        <!-- zoom area -->
        <Style x:Key="ZoomAreaStyle" TargetType="{x:Type StackPanel}">
            <Setter Property="Opacity" Value=".3" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
            <Setter Property="Margin" Value="15" />
            <Style.Triggers>
                <EventTrigger RoutedEvent="MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource FadeInAnimation}" />
                    </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="MouseLeave">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource FadeOutAnimation}" />
                    </EventTrigger.Actions>
                </EventTrigger>
            </Style.Triggers>
        </Style>

        <!-- zoom slider -->
        <Style x:Key="ZoomSliderStyle" TargetType="{x:Type Slider}">
            <Setter Property="Width" Value="20" />
            <Setter Property="Height" Value="70" />
            <Setter Property="Cursor" Value="Arrow" />
            <Setter Property="Orientation" Value="Vertical" />
            <Setter Property="TickPlacement" Value="None" />
            <Setter Property="SmallChange" Value="0.1" />
            <Setter Property="LargeChange" Value=".25" />
            <Setter Property="Maximum" Value="10" />
            <Setter Property="Minimum" Value=".10" />
            <Setter Property="IsSnapToTickEnabled" Value="False" />
        </Style>

        <!-- zoom label -->
        <Style x:Key="ZoomLabelStyle" TargetType="{x:Type Label}">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="Foreground" Value="White" />
        </Style>

        <!-- distance area -->
        <Style x:Key="TimeAreaStyle" TargetType="{x:Type StackPanel}">
            <Setter Property="Opacity" Value=".3" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
            <Setter Property="Margin" Value="15" />
            <Style.Triggers>
                <EventTrigger RoutedEvent="MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource FadeInAnimation}" />
                    </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="MouseLeave">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource FadeOutAnimation}" />
                    </EventTrigger.Actions>
                </EventTrigger>
            </Style.Triggers>
        </Style>

        <!-- distance slider -->
        <Style x:Key="DistanceSliderStyle" TargetType="{x:Type Slider}">
            <Setter Property="Width" Value="20" />
            <Setter Property="Height" Value="70" />
            <Setter Property="Cursor" Value="Arrow" />
            <Setter Property="Orientation" Value="Vertical" />
            <Setter Property="TickPlacement" Value="None" />
            <Setter Property="SmallChange" Value="1" />
            <Setter Property="IsSnapToTickEnabled" Value="True" />
        </Style>

        <!-- distance label -->
        <Style x:Key="TimeLabelStyle" TargetType="{x:Type Label}">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="Foreground" Value="White" />
        </Style>

        <!-- slider border -->
        <Style x:Key="SliderBorderStyle" TargetType="{x:Type Border}">
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="CornerRadius" Value="10" />
            <Setter Property="Background" Value="#80000000" />
            <Setter Property="BorderBrush" Value="#80ffffff" />
            <Setter Property="Padding" Value="7" />
        </Style>
    </UserControl.Resources>
    <UserControl.ContextMenu>
        <ContextMenu>
            <MenuItem x:Name="mnuRedraw" Header="Refresh graph" Click="mnuRedraw_Click"/>
            <Separator/>
            <MenuItem x:Name="mnuVisualSetting" Header="Visuals">
                <MenuItem x:Name="mnuVerticeVisual" Header="Vertice visual" Click="mnuVerticeVisual_Click"/>
                <MenuItem x:Name="mnuEdgeVisual" Header="Edge visual" Click="mnuEdgeVisual_Click"/>
            </MenuItem>
            <MenuItem
                x:Name="mnuFilter" Header="Filter">
                <MenuItem x:Name="mnuExclude" Header="Exclude" Click="mnuExclude_Click"/>
                <MenuItem x:Name="mnuInclude" Header="Select" Click="mnuInclude_Click"/>
            </MenuItem>
            <MenuItem x:Name="mnuDedup" Header="Dedup" Click="mnuDedup_Click"/>
            <Separator/>
            <MenuItem
				Name="cmu_ExplorePublications"
				Header="-> publications" 
				Tag="../images/doc.png" 
                Click="cmu_ExplorePublications_Click"/>
            <MenuItem 
				Name="cmu_ExploreOrganizations"
				Header="-> organizations" 
				Tag="../images/home.png" 
                Click="cmu_ExploreOrganizations_Click"/>
            <MenuItem 
				Name="cmu_ExplorePersons"
				Header="-> persons" 
				Tag="../images/user.png" 
                Click="cmu_ExplorePersons_Click"/>
            <MenuItem 
				Name="cmu_ExploreGrants"
				Header="-> grants" 
				Tag="../images/user.png" 
                Click="cmu_ExploreGrants_Click"/>
        </ContextMenu>
    </UserControl.ContextMenu>
    <Grid>
        <Border 
            x:Name="graphBorder"
            CornerRadius="10" Background="Black" 
            BorderBrush="Gray" 
            BorderThickness="2">
            <ScrollViewer x:Name="ScrollViewer" Style="{StaticResource ScrollViewerStyle}">
                <RadialDiagrams:RadialGraphCanvas x:Name="radialGraph" VerticeSelected="radialGraph_VerticeSelected"/>
            </ScrollViewer>
        </Border>

        <!-- zoom -->
        <!--<StackPanel Style="{StaticResource ZoomAreaStyle}" x:Name="ZoomSliderPanel">
            <Border Style="{StaticResource SliderBorderStyle}">
                <StackPanel>
                    <Slider 
                        Style="{StaticResource ZoomSliderStyle}" 
                        x:Name="ZoomSlider" ValueChanged="ZoomSlider_ValueChanged"/>
                    <Label Style="{StaticResource ZoomLabelStyle}">Zoom</Label>
                </StackPanel>
            </Border>
        </StackPanel>-->

        <!-- distance -->
        <StackPanel Style="{StaticResource TimeAreaStyle}">
            <Border Style="{StaticResource SliderBorderStyle}">
                <StackPanel>
                    <Label Style="{StaticResource TimeLabelStyle}" Content="{Binding ElementName=DistanceSlider, Path=Value}" />
                    <Slider 
                        Style="{StaticResource DistanceSliderStyle}" 
                        x:Name="DistanceSlider" />
                    <Label Style="{StaticResource TimeLabelStyle}">Distance</Label>
                </StackPanel>
            </Border>
        </StackPanel>
    </Grid>
</UserControl>
